﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using BusinessTier.Facade.Interface;
using BusinessTier.Facade.Implementation;
using Domain.Type;
using Domain;
using Domain;
using WebMVC.Helpers;
using WebMVC.Areas.AdminPanel.Models;


namespace WebMVC.Areas.AdminPanel.Controllers
{
    public class ProductMgmtController : Controller
    {

        private static readonly int ITEMS_COUNT = 50;
        private IProductService productService;
        private IStaticDataService staticDataService;


        public ProductMgmtController()
            : this(new ProductService(), new StaticDataService())
        {

        }

        public ProductMgmtController(IProductService productService, IStaticDataService staticDataService)
        {
            this.productService = productService;
            this.staticDataService = staticDataService;
        }

        public ActionResult Index(string type, int? page)
        {
            /*
            page = page.HasValue ? page : page = 1;
            ProductFilter filter = new ProductFilter()
            {
                ProductType = type,
                SkipItems = (page.Value - 1) * ITEMS_COUNT,
                TakeItems = ITEMS_COUNT
            };

            List<ProductViewModel> modelList = new List<ProductViewModel>();
            foreach (ProductDO prod in productService.GetFilteredProducts(filter))
            {
                modelList.Add(new ProductViewModel()
                {
                    Id = prod.Id,
                    Name = prod.NameEn,
                    ThumbnailPath = FileStoreHelper.GetProdThumbnailPath(prod.Id, prod.TypeKey),
                    StyleCode = staticDataService.GetStyleById(prod.Style.Id).NameEn,
                    IndustryCode = staticDataService.GetIndustryById(prod.Industry.Id).NameEn,
                    CreateDate = prod.CreateDate
                });
            }


            int itemCount = productService.GetFilteredProductsCount(filter);
            int pageCount = itemCount / ITEMS_COUNT;
            if ((itemCount % ITEMS_COUNT) != 0)
            {
                pageCount++;
            }
            var pagingModel = new PagingViewModel()
            {
                CurrentPage = page.Value,
                TotalPages = pageCount
            };

            ViewData["pages"] = pagingModel;

            return View(modelList);
             * */
            return View();

        }

        public ActionResult Details(long id)
        {
            return View();
        }

        [HttpGet]
        public ActionResult CreateBusinessCard()
        {
            return View();
        }
    }
}